<template>
  <div>
    <el-form  label-width="80px" style="text-align: left;">
      <el-form-item label="病人姓名">
        <el-input v-model="param.caseName" :readonly="true"></el-input>
      </el-form-item>
      <el-form-item label="填写医生" >
        <el-select placeholder="请选择" v-model="param.ciWorkerId">
        <el-option :label="doctor.wkName" :key="doctor.id" :value="doctor.id" v-for="doctor in allDoctor"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="住院科室">
          <el-select placeholder="请选择科室" v-model="param.ciDescription">
            <el-option :label="inpatientDepartment.deName" :key="inpatientDepartment.id" :value="inpatientDepartment.id" v-for="inpatientDepartment in inpatientDepartmentList"></el-option>
          </el-select>
      </el-form-item>
      <el-form-item label="医生描述">
        <el-input type="textarea" v-model="param.ciContent"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="addMedicalRecord">确定</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  props:{
        message: {
          type: Object,
          required: true
        }
      },

  data() {
    return {
      param:{},
      allDoctor:[],
      inpatientDepartmentList:[],
    }
  },

  methods: {
    queryAllDoctor(){
      this.$axios.get('api/doctor/queryAllDoctor').then(resp=>{
        if(resp.data.code==200){
          this.allDoctor=resp.data.data
          // console.log(resp.data)
        }
      })
    },

    queryInpatientDepartment(){
        this.$axios.get("api/request/queryInpatientDepartment").then(resp=>{
          if(resp.data.code==200){
            this.inpatientDepartmentList=resp.data.data
          }
        })
      },

      addMedicalRecord(){
        this.$axios.post('api/doctor/addMedicalRecord',this.param).then(resp=>{
          if(resp.data.code==200){
            this.$message({
                showClose: true,
                message: '已提交病例表',
                type: 'success'
            });
            this.param.ciWorkerId=''
            this.param.ciDescription=''
            this.param.ciContent=''
          }
        })
      },

    text(){
      this.param.ciCaseId=this.message.caseId
      this.param.caseName=this.message.caseName
     }
  },
  created(){
    this.text()
    this.queryAllDoctor()
    this.queryInpatientDepartment()
  }
}
</script>

<style scoped>
</style>